<template>
  <div class="divBox relative">


    <el-card class="box-card">
      <el-row style="margin-bottom: 20px;">
        <el-button size="small" type="primary" @click="getDangerList(0)" class="mr10" >查询隐患</el-button>
        <el-button size="small" type="danger" @click="getDangerList(7)" class="mr10" >临期隐患（7天）</el-button>
      </el-row>
      <el-pagination
        layout="total,prev, pager, next"
        :current-page="tableData.current"
        :total="tableData.total"
        :page-size="tableData.size"
        @current-change="pageChange"
      >
      </el-pagination>

      <el-table
        v-loading="listLoading"
        :data="tableData.records"
        style="width: 100%"
        size="mini"
        :highlight-current-row="true"
        :header-cell-style=" {fontWeight:'bold'}"
      >
        <el-table-column
          prop="hdDesc"
          label="隐患描述"
          width="320">
        </el-table-column>
        <el-table-column
          prop="entFullName"
          label="企业名称"
          width="180">
        </el-table-column>
        <el-table-column
          prop="checkTime"
          label="排查日期"
          width="150">
        </el-table-column>
        <el-table-column
          prop="hdLevelName"
          label="隐患等级"
          width="90">
        </el-table-column>
        <el-table-column
          prop="prodAddrName"
          label="行政区划"
          width="90">
        </el-table-column>
        <el-table-column
          prop="industryTypeName"
          label="行业类别"
          >
        </el-table-column>
        <el-table-column
          prop="neatenLimitDate"
          label="整改期限"
          width="100">
        </el-table-column>
        <el-table-column
          prop="hdSourceName"
          label="隐患来源"
          >
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
import {dangerList,sendSafeSms} from '@/api/safe'

export default {
  name:"DangerList",
  data(){
    return{
      days:30,
      listLoading: true,
      tableData:{
        total:0,
        current:1,
        pages:0,
        size:10,
        records:[]
      },
      nearDayStart:0,
      nearDayEnd:0
    }
  },
  mounted() {
    this.getDangerList(0)
  },
  methods:{
    getDangerList(nearDayEnd){
      this.nearDayEnd=nearDayEnd
      this.listLoading = true
      dangerList(this.days,this.tableData.current,0,nearDayEnd,"330285").then(res=>{
        console.log(res)
        this.tableData.total=res.total
        this.tableData.current=res.current
        this.tableData.pages=res.pages
        this.tableData.records=res.records
        this.listLoading = false
      }).catch(res=>{
        this.listLoading = false
        this.$message.error(res.message)
      })
    },
    pageChange(page) {
      console.log(page)
      this.tableData.current = page
      this.getDangerList(this.nearDayEnd)
    },
    sendSms(){
      sendSafeSms().then(res=>{
        this.$message.success("发送成功")
      }).catch(res=>{
        this.$message.error(res.message)
      })
    }
  }
}
</script>

<style scoped>

</style>
